public class CardDeck {
	protected Card[] cards;
	protected int top;
	
	public CardDeck() {
		top = 0;
		char[] suits = Card.getSuits();
		int numValues = Card.MAX - Card.MIN + 1; //14 - 2 + 1 = 13
		cards = new Card[suits.length * numValues]; // 4 * 13 = 52
		int cIndex;
		for (int s = 0; s < suits.length; s++) {
			for (int v = Card.MIN; v <= Card.MAX; v++) {
				cIndex = s * numValues + v - Card.MIN; //EG: 2 * 13 + 10 - 2 = 34th card
				cards[cIndex] = new Card(v, suits[s], true);
			}
		}
	}
	
	public Card getCard(int index) {
		return cards[index];
	}
	
	public void list() {
		for (int c = 0; c < cards.length; c++) {
			System.out.print(cards[c].toString() + " ");
		}
		System.out.println();
	}
	
	public int getTopIndex() {
		return top;
	}
	
	public Card deal() {
		Card dealt = cards[top];
		top++;
		if (top >= cards.length) reset();
		return dealt;
	}
	
	public void reset() {
		top = 0;
	}
	
	public int getNumCards() {
		return cards.length;
	}
	
	public int getNumCardsLeft() {
		return cards.length - top;
	}
}
